﻿using System;
using T4UtilityBelt.UxDesigns;
using T4UtilityBelt.UxDesigns.Controls;

namespace T4UtilityBelt.DataDesigns
{
    public class ParentMany : Parent
    {
        public ParentMany() 
            : base(null, null)
        {
            Multiplicity = Multiplicity.Many;
        }

        public ParentMany(string name, string toName)
            : base(name, toName)
        {
            Multiplicity = Multiplicity.Many;
        }

        public ParentMany(string name, string toName, bool required)
            : base(name, toName, required)
        {
            Multiplicity = Multiplicity.Many;
        }


        public override bool IsMultiplicitySpecified
        {
            get { return Multiplicity != Multiplicity.Many; }
        }


        public override Control CreateControl()
        {
            return new ParentManyControl(this);
        }

        public override string RenderModelCs()
        {
            return string.Format(@"
		private {1}Collection _{0} = new {1}Collection();
        /// <summary>
        /// Gets or sets the {0}.
        /// </summary>
        /// <value>
        /// The {0}.
        /// </value>
        public {1}Collection {0} 
		{{
			get 
			{{ 
				return _{0}; 
			}} 
		}}
", Name, ToName);
        }


        public override string RenderAssignFromModelToServiceCs(string toControl, string fromControl)
        {
            throw new NotImplementedException();

            //foreach (var sl in model.<#=name#>)
            //{
            //    service.<#=name#>.Add(Mapper.CreateServiceFromModel<<#=listName#>Item, <#=propertyType#>>(dataContext, sl));
            //}

        }

        public override string RenderAssignFromServiceToModelCs(string toControl, string fromControl)
        {
            throw new NotImplementedException();

            //model.<#=name#>.Clear();
            //foreach (var sl in service.<#=name#>)
            //{
            //    model.<#=name#>.Add(Mapper.CreateModelFromService<<#=propertyType#>, <#=listName#>Item>(sl));
            //}

        }
    }
}